package Test.SynchronousQueueDemo;

import java.util.concurrent.SynchronousQueue;

/**
 * @author pengshuai
 * @date 2022/1/27 21:43
 */
public class Demo03 {

    public static void main(String[] args) throws InterruptedException {

        SynchronousQueue<Integer> queue = new SynchronousQueue<>(true);

        Thread thread = new Thread(() -> {
            try {
                queue.put(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        thread.start();

        Thread.sleep(1000);

        new Thread(() -> {
            try {
                queue.put(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();


        Thread.sleep(100);
        thread.interrupt();




    }


}
